<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>新增临时培训</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/webuploader-0.1.5/webuploader.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=f5a12a1d">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        .blockElement {
            position: fixed !important;
            top: 50% !important;
        }

        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .table-detail td.td-value2 {
            padding: 1px !important;
            text-align: left !important;
        }

        .pull-left {
            float: left;
            padding-left: 6px;
        }

        .td-value2 input {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
        }

        .td-value2 select {
            box-shadow: inset 1px 1px 4px #333;
            height: 100% !important;
            padding-left: 4px !important;
            color: #2a8cec;
        }

        .lineOne {
            text-align: left;
        }

        span {
            padding-left: 6px
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .user:hover {
            background-color: #cfd4d1;
        }

        .userbox .select.user {
            color: #fff;
            background-color: #045B9E;
        }

        .span-btn {
            position: absolute;
            left: -2px;
            margin-top: 0px;
            cursor: pointer;
        }

        /*.auditorName {*/
        /*text-align: center;*/
        /*}*/

        .IcoNormal {
            float: left;
            border-bottom: 0px;
            border-left: 0px;
            background-color: transparent;
            width: 16px;
            height: 16px;
            vertical-align: middle;
            border-top: 0px;
            border-right: 0px;
            background-image: url(/dist/img/upload_normal.gif);
            background-repeat: no-repeat;
            float: left;
        }

        .progressobj {
            height: 20px;
        }

        .progressobj .delfile {
            float: left;
            margin-left: 10px;
        }

        .select {
            color: #fff;
            background-color: #045B9E;
        }

        td .sp-value {
            display: inline-block;
            padding-left: 6px;
            word-wrap: break-word;
        }

        td.td-title, td select, td .filename, td.td-module {
            color: black;
        }

        .table-detail-payee:nth-child(even) td.td-title {
            background-color: white;
        }

        .printDiv {
            display: none;
        }

        .printInput {
            width: 200px;
        }

        .printBtn {
            margin: 0 auto;
            display: block;
        }

        #divUploadedFiles {
            /*padding: 4px;*/
            padding-bottom: 0;
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 6px;
            height: 6px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 0px;
        }

        .moreListData {
            position: absolute;
            top: 30px;
            z-index: 111;
            display: none;
        }

        .moreListData .item {
            width: 100%;
            height: 30px;
            line-height: 30px;
        }

        .moreListData .item span {
            margin-right: 5px;
        }

        .ui_main {
            vertical-align: top;
        }

        .td20 {
            width: 20% !important;
        }

        .webuploader-pick {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            padding: 0 4px;
            height: 29px;
            line-height: 29px;
            margin: 0 auto;
            width: 80px;
            /*margin-top: 9px;*/
            border-radius: 4px;
            display: block;
        }

        .webuploader-pick-hover {
            color: #fff !important;
            background: url(/dist/img/fjT2.png) no-repeat 5px center;
            background-color: #0F6099;

        }

        .div-td-content-exam {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            padding: 8px 6px;
            border: 1px solid #d4d4d4;
            display: none;
            padding-bottom: 2px;
            background: #F9F9F9;
        }

        .div-td-content-exam .item {
            width: 10%;
            margin-right: 6px;
            margin-bottom: 6px;
            text-align: center;
            height: 30px;
            float: left;
            cursor: pointer;
            line-height: 30px;
        }

        .div-td-content-exam .item.active {
            background-color: #2a8cec;
            color: white;
            margin-right: 6px;
            margin-bottom: 6px;
        }

        .div-td-content-exam i {
            width: 15px;
            height: 12px;
            background: url(/dist/img/more-icon1.png);
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .noFj {
            background: url(/dist/img/fjT1.png) no-repeat 5px center;
            padding: 0 4px;
            height: 29px;
            line-height: 29px;
            margin: 0 auto;
            width: 80px;
            color: #ddd;
            cursor: no-drop;
            /* margin-top: 9px; */
            border-radius: 4px;
            display: block;
        }

        .user {
            height: 30px;
            line-height: 30px;
            max-height: 30px;
            float: left;
            text-align: left;
            min-width: 32px;
            padding-left: 1px;
            overflow: hidden;
            cursor: pointer;
        }

        .treeBox {
            height: 100vh;
            width: 100%;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 99999999999;
            background: #fff;
            text-align: center;
        }

        /*ztree*/
        .ztree li {

            line-height: 24px;
        }

        .ztree li span.button.ico_open {
            vertical-align: sub;
            margin-right: 6px;
        }

        .ztree li span.button.ico_close {
            vertical-align: sub;
            margin-right: 6px;
        }

        .ztree li span.button.chk {
            margin-right: 6px;
            margin-left: 6px;

        }

        .ztree li span.button.root_open {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.root_close {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.roots_open {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.roots_close {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.center_open {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.center_close {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.bottom_open {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.bottom_close {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.noline_open {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree li span.button.noline_close {
            transform: scale(1.4, 1.4);
            margin-top: -1px;
        }

        .ztree * {
            font-size: 14px;
        }

        .fj-tanzhongStyle .name {
            float: left;
            width: auto;
            height: 100%;
            line-height: 29px;
            position: relative;
            left: 0;
            top: 0;
        }

        .fj-tanzhongStyle .down {
            float: left;
            width: auto;
            height: 100%;
            line-height: 29px;
            position: relative;
            left: 0;
            top: 0;
            margin-left: 10px;
        }

        .fj-tanzhongStyle .del {
            float: left;
            width: auto;
            height: 100%;
            line-height: 29px;
            position: relative;
            left: 0;
            top: 0;
            margin-left: 10px;
        }


    </style>

</head>
<body>
<div class="oaLoad">
    <div class="loadGif" id="areaProgress"></div>
</div>
<section class="content iframeH" id="app">
    <div class="div-td-content-exam"><i></i>

        <div class="list" v-if="type==1">

            <div :class="item.select=='true'?'item active':'item'" v-for="item in companyList"
                 @click="selectItem(item)">{{item.name}}
            </div>
        </div>
        <div class="list" v-if="type==2">
            <div :class="item.select=='true'?'item active':'item'" v-for="item in departList" @click="selectItem(item)">
                {{item.departName}}
            </div>
        </div>
        <div class="list" v-if="type==3">
            <div :class="item.select=='true'?'item active':'item'" v-for="item in roleNameList"
                 @click="selectItem(item)">{{item.roleName}}
            </div>
        </div>
    </div>
    <table class="table-detail" border=0 cellSpacing=0 cellPadding=0 style="width: 100%; table-layout:auto">
        <tbody>
        <tr class="no-print">
            <td colspan="3" class=" no-print td-module " style=" background-color: yellow;">基本信息</td>
        </tr>
        <tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">培训内容</td>
            <td class="td-value" colspan="2"><input v-model="info.description" type="text"
                                                    v-if="pageType=='edit'"/>
                <span v-else>{{info.description}}</span>
            </td>
            <!--<td></td>-->
        </tr>

        <tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">截止时间</td>
            <td class="td-value" colspan="2"><input type="text"
                                                    v-model="info.endTime"
                                                    @focus="showDatePicker($event)" v-if="info.createUserId==userId||info.createUserId==''"
                                                    style="padding-left: 6px !important;text-indent: 0px;cursor: pointer"/>
                <span v-else>{{info.endTime}}</span>
                <!--<td style=" width: 90px"></td>-->
        </tr>
        <tr class="no-print">
            <!--<td style="background-color: rgb(245, 243, 243); width: 100px">培训材料</td>-->
            <td style=" width: 90px;background-color: rgb(245, 243, 243);">
                <div :class="pageType=='look'?'fujian fj noFujian':'fujian fj'" id="peiXun"
                     v-if="pageType=='edit'">上传附件
                </div>
                <!--<div v-else class="noFj">附&nbsp;&nbsp;&nbsp;件</div>-->
                <div v-else>培训材料</div>
            </td>
            <td colspan="2">
                <div class="fj-tanzhongStyle" v-for="(attach,i) in fileList" v-if="attach.name!=''">
                    <b :class="fjStyle(attach.name)"></b>
                    <div class="name" :title="attach.name"
                         :title="attach.name">{{attach.name}}
                    </div>
                    <div class="down"><a href="javascript:void(0)" class="nui-txt-link"
                                         v-on:click="download(attach.url,attach.name)">预览</a>
                    </div>
                    <div class="del"><a v-if="pageType=='edit'"
                                        href="javascript:void(0)" class="nui-txt-link"
                                        v-on:click="deleteFileRP(i)">删除</a></div>
                </div>
                <div style="text-align: left" v-if="!fileList||fileList.length<=0"><span
                        style="color: rgb(221, 221, 221);">可以上传图片、PDF、Excel、Word、PPT</span></div>
            </td>
            <!--  <td style=" width: 90px">
                  <div :class="pageType=='look'?'fujian fj noFujian':'fujian fj'" id="peiXun"
                       v-if="pageType=='edit'">上传附件
                  </div>
                  <div v-else class="noFj">上传附件</div>
              </td>-->
        </tr>
        <tr>
            <td colspan="3" style=" background-color: #d3e8fd;" class=" no-print td-module">
                <span style="margin-left: 80px;">考核人员</span>
                <span style="background-color:white;color:black;float: right;padding-right: 6px;margin-right: 2px;cursor: pointer;text-align: center;font-weight: bold;"
                      @click="lookUserList()">查看考核人员</span>
            </td>
        </tr>
        <!-- <tr class="no-print">
             <td style="background-color: rgb(245, 243, 243); width: 100px">公&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;司</td>
             <td class="td-value"><span>{{changeName(info.companyNames)}}</span></td>
             <td style="text-align: center !important;cursor: pointer;width: 90px" v-if="pageType=='edit'"
                 class="td-value changeValue" attr-type="1">选择
             </td>
             <td style=" width: 90px" v-else></td>

         </tr>-->

        <!--<tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">部&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;门</td>
            <td class="td-value"><span>{{changeName(info.departNames)}}</span></td>
            <td style="text-align: center !important;cursor: pointer;width: 90px" v-if="pageType=='edit'"
                class="td-value changeValue" attr-type="2">选择
            </td>
            <td style=" width: 90px" v-else></td>

        </tr>
        <tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位</td>
            <td class="td-value"><span>{{changeName(info.roleNames)}}</span></td>
            <td style="text-align: center !important;cursor: pointer;width: 90px" v-if="pageType=='edit'"
                class="td-value changeValue" attr-type="3">选择
            </td>
            <td style=" width: 90px" v-else></td>

        </tr>-->
        <tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">选择人员</td>
            <td style=" " colspan="2" class="td-value">
                <div style="padding-left:6px;">
                    <a href="javascript:void(0);" @click="selectStaff()"
                       v-if="pageType=='edit'||info. createUserId==userId"
                       style="color:#2a8cec;cursor: pointer;text-align: center;"
                    >{{info.haveKhFlag=='1'?'修改':'选择'}}</a>
                    <a href="javascript:void(0);" @click="lookUserList()" v-else
                       style="color:#2a8cec;cursor: pointer;text-align: center;"
                    >查看</a>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="3" style=" background-color: yellow;" class=" no-print td-module">培训试题</td>
        </tr>
        <tr class="no-print">
            <td style="background-color: rgb(245, 243, 243); width: 100px">培训试题</td>
            <!--<td class="td-value">
                &lt;!&ndash;<span v-if="info.state!=-1" style="color: black;">已编辑题目</span>&ndash;&gt;
            </td>-->
            <td class="td-value" style="border-right: 0px;">
                <div style="padding-left:6px;">
                    <a href="javascript:void(0);" v-if="pageType=='edit'"
                       style="color:#2a8cec;cursor: pointer;text-align: center" @click="saveMain('edit',1)"
                    >编辑&nbsp;&nbsp;</a>
                    <a href="javascript:void(0);" @click="see()" v-if="info.state!=-1"
                       style="color:#2a8cec;cursor: pointer;text-align: center"
                    >预览</a>
                    <a v-else style="color:#DDDDDD;cursor: pointer;text-align: center">预览</a>

                </div>
            </td>
            <td style=" width: 90px"></td>
        </tr>
        </tbody>
    </table>


    <!--审批进度-->
    <table class="table-detail " style="margin-top: 20px;table-layout: auto;">
        <td class=" td-module" colspan="5">审批进度</td>
        <tr>
            <td class="td-title" style="width:100px;">审核顺序</td>
            <td class="td-title" style="width:140px;">审核人员</td>
            <td class="td-title" style="width:100px;">审核状态</td>
            <td class="td-title" style="width:140px;">审核时间</td>
            <td class="td-title">审核意见</td>
        </tr>
        <tr v-for="(item,i) in auditors">
            <td style="width: 100px;">
                <span style="font-size:20px;color: #2a8cec;" v-if="pageType=='edit'" class="span-btn"
                      @click="addItem(i)"> + </span>
                <span style="color: #2a8cec;padding-left: 0px">第{{i+1}}审核人</span>
                <span style="font-size:20px;left: 78px;color: #2a8cec;" v-if="pageType=='edit'" class="span-btn"
                      @click="delItem(i)"> - </span>
            </td>
            <td style="text-align: left;">
                <input class="auditorName" type="text"
                       :value="item.auditorName" :idx="i" v-if="pageType=='edit'"
                       style="width: 100%;border: none;outline: none;padding-left: 4px;color: #2a8cec;"/>
                <span v-else style="color: #2a8cec;">{{item.auditorName}}</span>
            </td>
            <td style="width: 100px;">
                <span v-if="item.auditFlag==0" style="color:red;">{{convertAuditFlagToName(item.auditFlag)}}</span>
                <span v-else style="color: #2a8cec;">{{convertAuditFlagToName(item.auditFlag)}}</span>
            </td>
            <td style="color: #2a8cec;">{{timeLong(item.auditTime)}}</td>
            <td>
                <span style="width: 100%;border: none;outline: none;padding-left: 4px;color: #2a8cec;">
                    {{item.auditAdvise}}
                </span>
            </td>
        </tr>
        <tr class="no-print">
            <td class="td-title" style="width:100px;">抄送人</td>
            <td colspan="4" class="td-value">
                <div id="user" style="padding-left:6px;"
                     v-on:click.stop="inputFocus('txtCopier')">
                    <div v-for="(user,i) in copiers" class="user"
                         v-bind:class="{ select: copierSelectedIdx == i }"
                         v-on:click="selectUser(i,'copierSelectedIdx')">{{user.copierName}};
                    </div>
                    <input id="txtCopier" v-if="pageType=='edit'" type="text" class="pull-left copier"
                           style="width: 100px;height:28px;padding-top: 2px !important;padding-left: 1px !important;"
                           @keyup.delete="deleteUser">
                </div>
            </td>
        </tr>
    </table>
    <!--历史驳回-->
    <table v-if="auditHistory && auditHistory.length>0" class="table table-bordered text-center "
           style="margin-top: 20px;margin-bottom: -1px;">
        <tr>
            <td class="td-title td-module" colspan="3"
                style="text-align: center;width: 100%;color: black;font-weight: bold">
                历史驳回记录
            </td>
        </tr>
    </table>
    <table class="table table-bordered text-center " v-if="auditHistory && auditHistory.length>0">
        <tr>
            <td class="td-title" style="width:100px;">驳回人员</td>
            <td class="td-title" style="width:240px;">驳回时间</td>
            <td class="td-title">驳回原因</td>
        </tr>
        <tr v-for="(item,i) in auditHistory">
            <td style="width:240px;">
                <span>{{item.auditorName}}</span>
            </td>
            <td style="width:240px;">{{timeLong(item.auditTime)}}</td>
            <td style="width: auto"><span class="td-tanZongStyle-line">{{item.auditAdvise}}</span></td>
        </tr>
    </table>
    <div style="height:30px;line-height:30px;text-align: center;z-index:999;padding-top:5px;margin-bottom: 15px">
        <input type="button" value="保存草稿" @click="saveMain('','',1,-1)"
               v-if="pageType=='edit'&&info.auditFlag!=0&info.auditFlag!=1"
               class="btn oaBtn btn-sm"
               style="margin-top:5px;">
        <input type="button" value="提交申请" @click="saveMain('','',1,0)"
               v-if="pageType=='edit'&&info.auditFlag!=0&info.auditFlag!=1"
               class="btn oaBtn btn-sm"
               style="margin-top:5px;">
        <input type="button" value="保存修改" @click="upEtime()"
               v-if="info.createUserId==userId&&(info.auditFlag==0||info.auditFlag==1)"
               class="btn oaBtn btn-sm"
               style="margin-top:5px;">
        <input type="button" value="通过" @click="audit('tongguo')"
               v-if="pageType=='look'&&info.currentAuditorId==userId&&info.auditFlag==0"
               class="btn oaBtn btn-sm"
               style="margin-left: 20px;">
        <input type="button" value="驳回" @click="audit('bohui')"
               v-if="pageType=='look'&&info.currentAuditorId==userId&&info.auditFlag==0"
               class="btn oaBtn btn-sm"
               style="margin-left: 20px;">
    </div>

</section>


<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=63aed32f"></script>
<script src="/page/apply/contract/Template.js?t=42e28def"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/js/pages/saleTarget/class.js"></script>

<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/webuploader-0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script>
    $(function () {
        $("body").on("click", ".changeValue", function (e) {
            var type = $(this).attr("attr-type");
            app.type = type;

            console.log(app.type)
            if (type == '1') {
                app.info.departNames = '';
                app.info.roleNames = '';
            }
            if (type == '2') {
                app.info.roleNames = '';
                app.selectDepart()
            }
            if (type == '3') {
                app.selectRoleName()
            }
            if ($(".div-td-content-exam").is(":hidden")) {
                el = $(this).parent().find(".td-value")
                $(".div-td-content-exam").css({
                    "width": el.outerWidth() + "px",
                    "left": el.offset().left,
                    "top": (el.offset().top + el.outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            } else {
                $(".div-td-content-exam").hide();
            }
        });
        $("body").on("click", ".div-td-content-exam", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-exam").hide();
        });
    });
</script>

<script>
    var app = new Vue({
        el: '#app',
        data: {
            copierSelectedIdx: -1,
            id: $.wyui.page.urlParams.id ? $.wyui.page.urlParams.id : '',
            page: $.wyui.page.urlParams.page ? $.wyui.page.urlParams.page : '1',
            pageType: $.wyui.page.urlParams.pageType ? $.wyui.page.urlParams.pageType : 'look',//页面类型
            isAdd: $.wyui.page.urlParams.isAdd ? $.wyui.page.urlParams.isAdd : 0,//页面类型
            userId: getCurrentUser().id,
            type: "1",
            isExit:$.wyui.page.urlParams.isExit,
            info: {
                title: "",
                id: this.id,
                description: "",
                endTime: "",
                auditFlag: -2,
                companyNames: "",
                departNames: "",
                roleNames: "",
                companyIds: "",
                createUserId: getCurrentUser().id,
                createUserName: getCurrentUser().name,
                repaymentAttachName: "",
                repaymentAttachUrl: "",
                state: -1,
                haveKhFlag: 0,
            },
            companyList: [],
            roleNameList: [],
            departList: [],
            companyNames: [],
            departNames: [],
            companyIds: [],
            roleNames: [],
            fileList: [],
            auditors: [],
            auditHistory: [],
            copiers: [],


        },
        methods: {
            timeLong: function (time) {
                if (time) {
                    return new Date(time).Format(TimeFormat.long)
                } else {
                    return '';
                }
            },
            selectUser: function (i, prop) {
                this.copierSelectedIdx = -1;
                this[prop] = i;
            },
            deleteUser: function (event) {
                if (event.keyCode == 46 || event.keyCode == 8 && event.target.value == "") {
                    if (this.copierSelectedIdx > -1) {
                        this.copiers.splice(this.copierSelectedIdx, 1);
                        this.copierSelectedIdx = -1;
                    } else {
                        this.copierSelectedIdx = this.copiers.length - 1;
                    }
                }
            },
            audit: function (type) {
                var that = this;
                if (type == 'tongguo') {
                    /* if (!confirm("确定要通过吗？")) {
                         return;
                     }*/
                    top.$.alert({
                        win: this,
                        height: 180,
                        width: 300,
                        icon: '3', //1成功 2失败 3提示 不穿代表无图标
                        title: '确定要通过吗？',

                        blankclose: true,//点击空白是否可关闭
                        ok: "通过",//是否显示确认按钮,
                        okCallback: function (em, opts) {
                            //确认按钮回调
                            em.remove()
                            opts.close && opts.close()
                            advise = '同意！';
                            $.wyui.postLoadMethod(urlConfig.exam.applyAudit, {
                                id: that.id,
                                auditFlag: 1,
                                advise: '同意!',
                                userId: that.userId
                            }, function (r) {
//                                top.refreshTabByName("培训管理", "no");
                                if(that.isExit=='1'){
                                    var $iframe = top.findIframeByName("培训管理");
                                    $iframe[0].contentWindow.refresh();
                                }
                                setTimeout(function () {
                                    top.closeTabByPageId("xzpx");
                                    top.closeTabByPageId("xzpxst");
                                }, 500);

                            }, false, true)
                        },
                        cancel: "取消",
                        cancelCallback: function (em, opts) {
                            em.remove()
                            opts.close && opts.close()
                        }
                    })
                } else {
                    that.copierReturn();
                    return;
                }
            },
            copierReturn: function () {
                var that = this;
                $.dialog({
                    content: 'url:/page/exam/returnReason.html?id=' + that.id + "&t=" + new Date(),
                    title: '填写驳回原因',
                    width: 300,
                    height: 200,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            addItem: function (i) {
                this.auditors.splice(i + 1, 0, new SaleTarget.Audit());
                setTimeout(function () {
                    initAutoComplete();
                }, 300)
            },
            delItem: function (i) {
                if (this.auditors.length <= 1) {
                    top.$.alert({
                        win: this,
                        height: 180,
                        width: 300,
                        icon: '3', //1成功 2失败 3提示 不穿代表无图标
                        title: "请至少保留一位审核人！",
                        content: '',
                        blankclose: true,//点击空白是否可关闭
                        ok: "确定"
                    })
                    return
                }
                this.auditors.splice(i, 1);
            },
            convertAuditFlagToName: function (auditFlag) {
                //auditFlag:-1,0,1,2,3,4,5,6
                switch (auditFlag) {
                    case "-1":
                    case -1:
                        return "未提交";
                        break;
                    case "0":
                    case 0:
                        return "待审核";
                        break;
                    case "1":
                    case 1:
                        return "已通过";
                        break;
                    case "2":
                    case 2:
                        return "已驳回";
                        break;
                    default :
                        break;
                }
            },
            selectItem: function (item) {
                var check;
                if (this.type == '1') {
                    check = "companyNames"
                    this.checkedOne("companyIds", item.id);
                    this.checkedOne(check, item.name);
                } else if (this.type == '2') {
                    check = "departNames"
                    this.checkedOne(check, item.departName);
                } else {
                    check = "roleNames"
                    this.checkedOne(check, item.roleName);
                }
                if (item.select == "true") {
                    item.select = "false"
                } else {
                    item.select = "true"
                }
                console.log(item)

            },
            unselectUser: function () {
                this.copierSelectedIdx = -1;
            },
            changeName: function (string) {
                return string.replace(/,/g, "，")
            },
            selectDepart: function () {
                var that = this;
                $.wyui.postLoadMethod(urlConfig.exam.getDepartListByCompanyIds, {companyIds: that.info.companyIds}, function (data) {
                    console.log(data)

                    for (var i = 0; i < data.result.length; i++) {
                        if (that.info.departNames.indexOf(data.result[i].departName) != -1) {
                            data.result[i].select = "true";
                        } else {
                            data.result[i].select = "false"
                        }
                    }
                    if (that.info.departNames != "") {
                        that.departNames = that.info.departNames.split(",");
                    } else {
                        that.departNames = []
                    }
                    that.departList = data.result
                }, false, false)
            },
            selectRoleName: function () {
                var that = this;
                $.wyui.postLoadMethod(urlConfig.exam.getRoleNameListByCompanyAndDepart, {
                    companyIds: that.info.companyIds,
                    departNames: that.info.departNames
                }, function (data) {
                    console.log(data);
                    for (var i = 0; i < data.result.length; i++) {
                        if (that.info.roleNames.indexOf(data.result[i].roleName) != -1) {
                            data.result[i].select = "true";
                        } else {
                            data.result[i].select = "false"
                        }
                    }
                    if (that.info.roleNames != "") {
                        that.roleNames = that.info.roleNames.split(",");
                    } else {
                        that.roleNames = []
                    }
                    that.roleNameList = data.result
                }, false, false)
            },
            checkedOne: function (checkList, moduleKey) {
                var idIndex = this[checkList].indexOf(moduleKey)
                if (idIndex >= 0) {
                    this[checkList].splice(idIndex, 1)
                } else {
                    this[checkList].push(moduleKey)
                }
                var checkedString = "";
                if (this[checkList].length > 0) {
                    for (var i = 0; i < this[checkList].length; i++) {
                        if (this[checkList][i] != "") {
                            checkedString += this[checkList][i] + ",";
                        }
                    }
                    this.info[checkList] = checkedString.substring(0, checkedString.length - 1);
                } else {
                    this.info[checkList] = ""
                }
                console.log(this.info)
            },
            fjStyle: function (fjName) {
                if (fjName) {
                    var type = fjName.substring(fjName.lastIndexOf('.') + 1);
                    return 'img fj-' + type
                }
                return 'img'
            },
            inputFocus: function (id) {
                $("#" + id).focus();
            },
            download: function (attachUrl, fileName) {
                var sUrl = "https://docview.mingdao.com/op/view.aspx?src=" + attachUrl;
                var fileType = fileName.substring(fileName.lastIndexOf("."));
                switch (fileType) {
                    case ".png":
                    case ".jpeg":
                    case ".jpg":
                    case ".pdf":
                        downloadFilePDF(attachUrl, fileName);
                        break;
                    case ".ppt":
                    case ".pptx":
                    case ".doc":
                    case ".docx":
                    case ".xls":
                    case ".xlsx":
                        top.addTabs({
                            id: 'newAttachExam',
                            title: fileName,
                            close: true,
                            url: 'exam/previewPC.html?attachUrl=' + attachUrl + '&fileName=' + fileName,
                        });
                        break;
                    default:
                        downloadFilePDF(attachUrl, fileName);
                        break;
                }
                return false;
            },
            deleteFileRP: function (i) {
                var that = this;
                if (window.confirm("确定要删除该附件吗?")) {
                    that.fileList.splice(i, 1);
                    $("#peiXun").show();
                    //that.init();
                }

            },
            showDatePicker: function (e, item, type) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.info.endTime = dp.cal.getNewDateStr();
                        return true;
                    },
                    dateFmt: 'yyyy-MM-dd HH:mm'
                });
                $(e.target).blur();
            },
            lookUserList: function () {
                var that = this;
                top.$.dialog({
                    content: 'url:exam/tempExamUserList.html?id=' + that.info.id + '&userType=' + 0,
                    title: '',
                    width: 500,
                    height: 525,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            upEtime: function () {
                var that = this;
                $.wyui.postLoadMethod("/exam/updateEndTime.json", {
                    id: that.info.id,
                    endTime: that.info.endTime
                }, function (data) {
                    that.info.id = data.id;
                    top.$.alert({
                        win: this,
                        height: 180,
                        width: 300,
                        icon: '3', //1成功 2失败 3提示 不穿代表无图标
                        title: "修改成功",
                        content: '',

                        blankclose: true,//点击空白是否可关闭
                        ok: "确定"
                    })
                    top.refreshTabByName("培训管理", "no");
                    top.closeTabByPageId("xzpxst");
                    top.closeTabByPageId("xzpx");
                }, false, true)
            },
            houZui: function (name) {
                var that = this;
                if (name) {
                    var type = name.substring(name.lastIndexOf('.') + 1);
                    console.log(type)
                    var houZui = 'jpg gif png bmp tif emf wmf ico raw';
                    if (houZui.indexOf(type) >= 0) {
                        return true;
                    } else {
                        return false;
                    }
                    return true;
                } else {
                    if (that.info.repaymentAttachUrl.indexOf('jpg') != -1 || that.info.repaymentAttachUrl.indexOf('gif') != -1 || that.info.repaymentAttachUrl.indexOf('png') != -1 || that.info.repaymentAttachUrl.indexOf('bmp') != -1 || that.info.repaymentAttachUrl.indexOf('tif') != -1 || that.info.repaymentAttachUrl.indexOf('emf') != -1 || that.info.repaymentAttachUrl.indexOf('ico') != -1 || that.info.repaymentAttachUrl.indexOf('raw') != -1 || that.info.repaymentAttachUrl.indexOf('wmf') != -1) {
                        return true;
                    } else {
                        return false;
                    }
                }
                return false;
            },
            selectStaff: function () {
                var that = this;
                delete that.info.createTime;
                that.info.copiers = that.copiers;
                that.info.auditors = that.auditors;
                if (that.info.auditFlag != 0 && that.info.auditFlag != 1) {
                    if (that.info.auditFlag == -2) {
                        that.info.auditFlag = -2;
                    }
                    if (that.fileList && that.fileList.length > 0) {
                        var repaymentAttachNames = '';
                        var repaymentAttachUrls = '';
                        for (var i = 0; i < that.fileList.length; i++) {
                            repaymentAttachNames += that.fileList[i].name + ",";
                            repaymentAttachUrls += that.fileList[i].url + ",";
                        }
                        that.info.repaymentAttachName = repaymentAttachNames.substring(0, repaymentAttachNames.length - 1);
                        that.info.repaymentAttachUrl = repaymentAttachUrls.substring(0, repaymentAttachUrls.length - 1);
                    }
                    $.wyui.postLoadMethod(urlConfig.exam.saveExamMain, trimRN(that.info), function (data) {
                        that.info.id = data.id;
                        top.$.dialog({
                            content: 'url:exam/selectStaff.html?userId=' + getCurrentUser().id + '&mainId=' + that.info.id,
                            //title: '考核人员',
                            title: '',
                            width: 500,
                            height: 580,
                            max: true,
                            min: true,
                            lock: true
                        })
                    }, false, true);
                } else {
                    top.$.dialog({
                        content: 'url:exam/selectStaff.html?userId=' + getCurrentUser().id + '&mainId=' + that.info.id,
                        //title: '考核人员',
                        title: '',
                        width: 500,
                        height: 580,
                        max: true,
                        min: true,
                        lock: true
                    });
                }
            },
            /*checkUpLoad: function () {
                var that = this;
                if (that.fileList.length > 0 && that.fileList[0] && !that.houZui(that.fileList[0].name)) {
                    top.$.alert({
                        win: that,
                        height: 200,
                        width: 340,
                        icon: '3', //1成功 2失败 3提示 不穿代表无图标
                        title: "非图片类文件只能上传一个",
                        content: '',
                        blankclose: true,//点击空白是否可关闭
                        ok: "确定"
                    })
                }
            },*/
            init: function () {
                var that = this
                setTimeout(function () {
                    $(".fj").each(function () {
                        var demo = $(this);
                        var name = demo.attr("id");//signature
                        console.log(name)
                        var uploader = WebUploader.create({
                            // 选完文件后，是否自动上传。
                            auto: true,
                            // swf文件路径
                            swf: "/statics/plugin/webuploader-0.1.5/Uploader.swf",
                            // 文件接收服务端。
                            server: server.fjIp + "/attach/uploadFile.json",
                            // 选择文件的按钮。可选。
                            /* accept: {
                             title: 'Images',
                             extensions: 'gif,jpg,jpeg,bmp,png',
                             mimeTypes: 'image/!*'
                             },*/
                            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                            pick: '#' + demo.attr("id"),
                            duplicate: true
                        });
                        // 文件上传过程中创建进度条实时显示。
                        uploader.on('uploadProgress', function (file, percentage) {

                            var $li = $('#' + file.id),
                                $percent = $li.find('.progress span');
                            // 避免重复创建
                            if (!$percent.length) {
                                $percent = $('<p class="progress"><span></span></p>')
                                    .appendTo($li)
                                    .find('span');
                            }
                            $percent.css('width', percentage * 100 + '%');
                        });
                        uploader.on("uploadStart", function () {
                            $(".oaLoad").show();
                        });
                        uploader.on("uploadComplete", function () {
                            setTimeout(function () {
                                $(".oaLoad").hide();
                            }, 300)
                        });
                        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                        uploader.on('uploadSuccess', function (file, response) {
                            /* that.info.repaymentAttachName = response.name,
                             that.info.repaymentAttachUrl = response.url*/

                            if (response.name && response.name != '') {
                                var attach = {
                                    name: response.name,
                                    url: response.url
                                }
                                that.fileList.push(attach);
                            }
                            //$("#peiXun").hide();
                        });
                        // 文件上传失败，显示上传出错。
                        uploader.on('uploadError', function (file) {
                            top.$.alert({
                                win: this,
                                height: 180,
                                width: 300,
                                icon: '2', //1成功 2失败 3提示 不穿代表无图标
                                title: "上传失败！",
                                content: '',

                                blankclose: true,//点击空白是否可关闭
                                ok: "确定"
                            })
                        });
                    });
                }, 500);

            },
            see: function () {
                var that = this;
                top.$.dialog({
                    content: 'url:/page/exam/preview.html?mainId=' + that.info.id + '&pageType=' + 'look' + '&goback=' + 0,
                    //title: '预览详情',
                    title: '',
                    width: 404,
                    height: 570,
                    max: true,
                    min: true,
                    lock: true,
                });
            },
            saveMain: function (pageType, goback, save, auditFlag) {
                //预览 -1 look
                //编辑 0 edit
                //发布 1
                debugger
                var that = this;
                delete that.info.createTime;
                if (save && that.info.auditFlag == 0) {
                    that.info.state = 1;
                }
                if (that.info.state == 1 && goback == 1) {
                    that.info.state = 0;
                }
                if (that.fileList && that.fileList.length > 0) {
                    var repaymentAttachNames = '';
                    var repaymentAttachUrls = '';
                    for (var i = 0; i < that.fileList.length; i++) {
                        repaymentAttachNames += that.fileList[i].name + ",";
                        repaymentAttachUrls += that.fileList[i].url + ",";
                    }
                    that.info.repaymentAttachName = repaymentAttachNames.substring(0, repaymentAttachNames.length - 1);
                    that.info.repaymentAttachUrl = repaymentAttachUrls.substring(0, repaymentAttachUrls.length - 1);
                }
                if (that.info.state && that.info.state == 1) {
                    that.info.auditFlag = 0;
                }

                if (auditFlag || auditFlag == 0 || auditFlag == -1) {
                    that.info.auditFlag = auditFlag;
                }
                that.info.copiers = that.copiers;
                that.info.auditors = that.auditors;
                if(that.info.createUserId==''){
                    that.info.createUserId=that.userId;
                }
                if (that.info.auditFlag == 0) {
                    if (that.info.description == '') {
                        that.info.auditFlag = -2;
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "请填写培训内容",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                        return;
                    }
                    if (that.info.endTime == '') {
                        that.info.auditFlag = -2;

                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "请填写截止时间",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                        return;
                    }
                    if (that.info.repaymentAttachUrl == '') {
                        that.info.auditFlag = -2;
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "请上传培训材料",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                        return;
                    }
                    if (that.info.haveKhFlag != 1) {
                        that.info.auditFlag = -2;
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "请选择考核人员",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                        return;
                    }
                    if (that.info.state != 0) {
                        that.info.state = -1;
                        that.info.auditFlag = -2;
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "请编辑培训试题",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                        return;
                    }
                }

                $.wyui.postLoadMethod(urlConfig.exam.saveExamMain, trimRN(that.info), function (data) {
                    that.info.id = data.id;
                    console.log(that.info.id)
                    //pageType
                    if (!save && pageType && pageType != '') {
                        top.addTabs({
                            id: 'xzpxst',
                            title: '新增培训试题',
                            close: true,
                            url: 'exam/create.html?pageType=' + pageType + '&mainId=' + that.info.id + "&goback=" + goback
                        }, false, false)
                    }
                    if (save && save == 1) {
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '1', //1成功 2失败 3提示 不穿代表无图标
                            title: that.info.auditFlag == '0' ? '提交成功' : '保存成功',
                            content: '',
                            blankclose: false,//点击空白是否可关闭
                            cancel: "确定",
                            cancelCallback: function (em, opts) {
                                em.remove()
                                opts.close && opts.close()
                                if (auditFlag == 0||auditFlag==-1) {
                                    var $iframe = top.findIframeByName("培训管理");
                                    $iframe[0].contentWindow.refresh();
                                    setTimeout(function () {
                                        top.closeTabByPageId("xzpx");
                                        top.closeTabByPageId("xzpxst");
                                    }, 500);
                                }
                            }
                        })
                    }
                }, false, true);
            },
        },
        mounted: function () {
            var that = this;
            that.init();
            var id = $.wyui.page.urlParams.id ? $.wyui.page.urlParams.id : '';
            that.info.id = id;
            pageType = $.wyui.page.urlParams.pageType ? $.wyui.page.urlParams.pageType : 'look';//页面类型
            isAdd = $.wyui.page.urlParams.isAdd ? $.wyui.page.urlParams.isAdd : 0;//页面类型

            if ((isAdd == 0) || pageType == 'edit') {
                //修改，掉借口
                $.wyui.postLoadMethod(urlConfig.exam.getExamMainById, {id: that.info.id}, function (data) {
                    that.info = data.result;
                    that.auditors = data.auditors;
                    that.copiers = data.copiers;
                    that.auditHistory = data.history;
                    for (var i = 0; i < that.auditors.length; i++) {
                        that.auditors[i].auditorName = that.auditors[i].auditorName + '-' + that.auditors[i].roleName;
                    }
                    var repaymentAttachNames = that.info.repaymentAttachName;
                    var repaymentAttachUrls = that.info.repaymentAttachUrl;
                    var repaymentAttachNameList = repaymentAttachNames.split(',');
                    var repaymentAttachUrlList = repaymentAttachUrls.split(',');
                    for (var i = 0; i < repaymentAttachUrlList.length; i++) {
                        if (repaymentAttachUrlList[i] && repaymentAttachUrlList[i].length > 0) {
                            var attach = {
                                name: repaymentAttachNameList[i],
                                url: repaymentAttachUrlList[i],
                            }
                            that.fileList.push(attach);
                        }
                    }
                    if (repaymentAttachUrlList[i] && repaymentAttachUrlList[i].length > 0) {
                        var attach = {
                            name: repaymentAttachNameList[i],
                            url: repaymentAttachUrlList[i],
                        }
                        that.fileList.push(attach);
                    }
                    setTimeout(function () {
                        initAutoComplete();
                    }, 300);
                    console.log(that.info)
                }, false, true)
            }
            if (isAdd && isAdd == '1') {
                that.pageType = 'edit';
                if (that.auditors && that.auditors.length > 0 && that.copiers && that.copiers.length > 0) {

                } else {
                    $.wyui.postLoadMethod(urlConfig.exam.getAuditAndCopierList, {userId: getCurrentUser().id}, function (data) {
                        that.auditors = data.auditors;
                        that.copiers = data.copiers;
                        for (var i = 0; i < that.auditors.length; i++) {
                            that.auditors[i].auditorName = that.auditors[i].auditorName + '-' + that.auditors[i].roleName;
                        }
                        setTimeout(function () {
                            initAutoComplete();
                        }, 300);
                    }, false, false)
                }

            }
            setTimeout(function () {
                initAutoComplete();
            }, 300);
        }

    })

</script>
<script>
    $(function () {
        initAutoComplete();
    });

    function initAutoComplete() {
        $(".auditorName,.copier").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                if ($(this).hasClass("auditorName")) {
                    var idx = $(this).attr("idx");
                    app.auditors[idx].userId = user.id;
                    app.auditors[idx].auditorName = user.name + "-" + user.roleName;
                    app.auditors[idx].roleName = user.roleName;
                } else if ($(this).hasClass("copier")) {
                    var userIds = new Array();
                    for (var i = 0; i < app.auditors.length; i++) {
                        userIds.push(app.auditors[i].userId);
                    }
                    for (var i = 0; i < app.copiers.length; i++) {
                        userIds.push(app.copiers[i].userId);
                    }
                    if ($.inArray(user.id, userIds) == -1) {
                        app.copiers.push({userId: user.id, copierName: user.name});
                    } else {
                        top.$.alert({
                            win: this,
                            height: 180,
                            width: 300,
                            icon: '3', //1成功 2失败 3提示 不穿代表无图标
                            title: "审核人、抄送人不能重复输入",
                            content: '',

                            blankclose: true,//点击空白是否可关闭
                            ok: "确定"
                        })
                    }
                    $(this).val("");
                } else if ($(this).hasClass("returnPayee")) {
                    app.main.returnPayeeId = user.id;
                    app.main.returnPayeeName = user.name;
                    app.main.returnPayeeRoleName = user.roleName;
                }
                return false;
            },
            height: 210,
            width: 300
        });
    }

</script>
</body>
</html>